<template>
  <view class="mine">
    <!-- <image src="../../static/api.png" mode="" class="portrait"></image> -->
    <!-- <view class="my-name">{{nickname }}</view> -->
    <image :src="headimgurl" mode="" class="portrait"></image>
    <view class="my-name">{{ nickname }}</view>
    <view class="main">
      <!-- <view class="main-nav" @click="goTel()">
				<image src="../../static/c1.png" mode=""></image>
				<view>我参加的活动</view>
			</view> -->
			<view class="main-nav" @click="goAct()">
				<image src="../../static/mine_task.png" mode=""></image>
				<view>我参加的活动</view>
			</view>
      <view class="main-nav" @click="goInfo()">
        <image src="../../static/userinfo.png" mode=""></image>
        <view>个人信息</view>
      </view>
      <view class="main-nav">
        <image src="../../static/certificate.png" mode=""></image>
        <view>志愿者证书</view>
        <view>(开发中)</view>
      </view>
    </view>
	<view class="main">
	  <view @click="goApplication()" class="main-nav">
        <image src="../../static/application.png" mode=""></image>
        <view>先进个人申请</view>
      </view>
		<view class="main-nav">
		</view>
		<view class="main-nav">
		</view>
	</view>
    <tabbar :current-index="3" />
  </view>
</template>

<script>
import tabbar from "@/components/tab-bar";

export default {
  data() {
    return {
      nickname: "微信昵称",
      headimgurl: "../../static/api.png",
      openId: "ogiDYs4eDr9DA2pofZeYsFQygtt4",
      routeUrl: "",
	  // baseUrl: 'http://vwekzh.natappfree.cc/jeecg-boot/',
	  baseUrl: 'http://weixiaokong.91xiaokong.com/jeecg-boot/'
    };
  },
  components: {
    tabbar,
  },
  onLoad() {
    let _this = this;
	let openId = uni.getStorageSync('openid');
	_this.openId = openId;
	// console.log(openId);
    let nickname = uni.getStorageSync("nickname");
    if (nickname != "undefined" && nickname) {
      _this.nickname = nickname ;
    }
	uni.request({
		method:"POST",
		url:_this.baseUrl + "rescue/hnjzRescueInformation/wx/user/info/?openId="+_this.openId,
		data:{
		},
		success(res) {
			_this.nickname = res.data.result.nickname;
			}
	})
	uni.setStorageSync("nickname",_this.nickname);
    let headimgurl = uni.getStorageSync("headimgurl");
    if (headimgurl) {
      _this.headimgurl = decodeURIComponent(headimgurl);
    }
	
	  // this.getUserInfo();
  },
  methods: {
	  // 去活动页面
	  goAct(){
		 uni.navigateTo({
		   url: "./mine_activity",
		 });
	  },
	  // 去先进个人申请页面
	  goApplication(){
		 uni.navigateTo({
		   url: "./application",
		 });
	  },
	  
    goTel() {
      uni.navigateTo({
        url: "./mine-tel",
      });
    },
    goInfo() {
      // let openid = uni.getStorageSync('openid')
      // if (openid) {
      // 	uni.navigateTo({
      // 		url:'./mine-info'
      // 	})
      // }else{
      // 	let routes = getCurrentPages();
      // 	let route = routes[routes.length - 1].route
      // 	console.log(route);
      // 	window.location.href = 'http://weixiaokong.91xiaokong.com/jeecg-boot/wx/mp/wxLoginShare?url=' + route;
      // }
      uni.navigateTo({
        url: "./mine-info",
      });
    },
    // 授权
    // 授权接口
    // getUserInfo() {
    //   window.location.href = _this.baseUrl + "wx/mp/wxLoginShare";
    // },
  },
};
</script>

<style>
.mine {
	margin-top: 50rpx;
  padding-bottom: 140rpx;
}
.portrait {
  width: 100rpx;
  height: 100rpx;
  display: block;
  margin: 0 auto;
  border-radius: 50%;
}
.my-name {
  margin: 0 auto;
  text-align: center;
  margin-bottom: 30rpx;
}
.main {
  width: 98%;
  margin: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  height: 400rpx;
  border-radius: 50rpx;
  background-color: #ffffff;
  box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.1);
}
.main-nav {
  width: 50%;
  text-align: center;
  margin-top: 120rpx;
}
.main-nav image {
  width: 100rpx;
  height: 100rpx;
}
</style>
